package com.isorf.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.isorf.mapper.linkmapper;
import com.isorf.pojo.links;
import com.isorf.service.Linkservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;

@Service
public class linkserviceimpl implements Linkservice {
    @Autowired
    private linkmapper linkmapper;



    @Override
    public Boolean deletelink(Integer id) {
        // 实现删除逻辑
        int result = linkmapper.deletelink(id);
        return result > 0;
    }

    @Override
    public Boolean batchDelete(List<Integer> ids) {
        int result = linkmapper.batchDelete(ids);
        return result > 0;
    }

    @Override
    public Boolean updateLink(links link) {
        int result = linkmapper.updateLink(link);
        return result > 0;
    }

    //分页查询
    @Override
    public PageInfo<links> pageList(int pageNum, int pageSize) {
        // 使用PageHelper.startPage方法设置分页参数
        PageHelper.startPage(pageNum, pageSize);
        // 查询所有用户数据，此时查询会被自动分页
        List<links> userList = (List<links>) linkmapper.pageList();
        // 使用PageInfo包装查询结果，便于页面使用
        return new PageInfo<>(userList);
    }



    @Override
    public Boolean addlink(links link) {  // 修正方法名：addLink -> addlink
        int result = linkmapper.addlink(link);
        if (result > 0) {
            return true;
        } else {
            return false;
        }
    }
}

